const mutations = {
  // SearchPanel
  setDepartments(state, val) {
    state.departments = val;
  },
  // Schedule
  setDepartment(state, val) {
    state.department = val;
  },
  setName(state, val) {
    state.name = val;
  },
  setSchedules(state, val) {
    state.schedules = val;
  },
  setDates(state, val) {
    state.dates = val;
  },
  setWhichWeek(state, val) {
    state.whichWeek = val;
  },
  setPage(state, val) {
    state.page = val;
  },
  setPageSize(state, val) {
    state.pageSize = val;
  },
  setTotal(state, val) {
    state.total = val;
  },
  // AddDialog
  setMainServiceTypeOptions(state, val) {
    state.mainServiceTypeOptions = val;
  },
  setSubServiceTypeOptions(state, val) {
    state.subServiceTypeOptions = val;
  },
  setNewDutyToken(state, val) {
    state.newDutyToken = val;
  },
  // EditDialog
  setEditTarget(state, val) {
    const { schedules } = state;
    const person = schedules.find(item => item.name === val.name);
    const dutysOnTheDay = person[val.day];
    const duty = dutysOnTheDay.find(item => item.time === val.time);
    const {
      predictServiceStartTime,
      predictServiceEndTime,
      detail: orderContent
    } = duty;
    const newEditTarget = {
      ...val,
      predictServiceStartTime,
      predictServiceEndTime,
      orderContent
    };
    state.editTarget = newEditTarget;
  }
};

export default mutations;
